﻿using AvaDemo.Models;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AvaDemo.Services
{
    public class DBContext
    {
        public IFreeSql GetDb()
        {
            var db = new FreeSql.FreeSqlBuilder()
            .UseConnectionString(FreeSql.DataType.PostgreSQL,
            $"Host=localhost; Port=5432; Database=StuDB; Username=postgres; Password=123456")
            .UseNoneCommandParameter(true)
            .Build();
            return db;
        }

        public async Task<List<PerInfo>> GetAllData()
        {
            using (var db = GetDb())
            {
                var da = await db.Select<PerInfo>().ToListAsync();
                return da;
            }
        }
    }
    // {8D10C787-93D5-4E5D-B4E7-C362B0E48899}


}
